<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-demo__dhclubearningsinfo}">
      <el-form :inline="true">
        <el-form-item>
          <el-input v-model="orderId" placeholder="根据订单编号进行查询" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="getDataListByOrderId"></el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
                style="width: 100%;">
        <el-table-column prop="orderId" label="订单编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="earnings" label="收益金额/元" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createTime" label="产生时间" header-align="center" align="center"></el-table-column>
      </el-table>
      <el-pagination
          :current-page="page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="limit"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="pageSizeChangeHandle"
          @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './dhclubearningsinfo-add-or-update'

export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/demo/dhclubearningsinfo/page',
        getDataListIsPage: true,
        exportURL: '/demo/dhclubearningsinfo/export',
        deleteURL: '/demo/dhclubearningsinfo',
        deleteIsBatch: true
      },
      orderId: '',
      dataListByOrderId: []
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    /**
     * 根据订单编号查询订单信息
     */
    getDataListByOrderId() {
      if (this.orderId === '') {
        this.query();
      } else {
        this.dataListLoading = true;
        this.$http.get('demo/dhclubearningsinfo/getDataListByOrderId/' + this.orderId)
            .then(({data: res}) => {
              this.dataListByOrderId.push(res.data);
              this.dataList = this.dataListByOrderId;
              this.dataListByOrderId = [];
              this.dataListLoading = false;
            }).catch(_ => {
        })
      }
    }
  }
}
</script>
